export const login = ({ username }) => {
    return new Promise((resolve, reject) => {
        const users = [
            {
                name: "Tom",
                role: "admin",
            },
            {
                name: "Mary",
                role: "user",
            },
        ];
        const matchedUser = users.find(user => user.name === username);
        if (matchedUser) {
            localStorage['userInfo'] = JSON.stringify(matchedUser);
            resolve(matchedUser);
        } else {
            reject("用户名不存在");
        }
    });
};
export const getUserInfo = ()=>{
    return new Promise((resolve,reject)=>{
        const storedUser = localStorage['userInfo'];
        if(storedUser){
            resolve(JSON.parse(storedUser));
        }else{
            reject("请先登录");
        }
    });
}